/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.yonsei.iwb.smarttv.userpreference;

import com.hp.hpl.jena.rdf.model.NodeIterator;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import edu.yonsei.iwb.smarttv.model.measure.Normalization;
import edu.yonsei.iwb.smarttv.model.measure.ResourceWeights;
import edu.yonsei.iwb.smarttv.model.measure.WeightModel;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

/**
 *
 * @author JDK
 */
public class UserProfile {
    
    private String id;
    private ResourceWeights prw;
    private boolean login = false;
            
    public UserProfile(String id, Hashtable<Resource, Integer> upt){
        this.id = id;
        this.initializePreferedResourceWeight(upt);
    }
    
    public UserProfile(String id){
        this.id = id;
        this.prw = new ResourceWeights();
    }
    
    public void addResourceWeight(String uri, double weight){
        this.prw.put(ResourceFactory.createResource(uri), weight);
    }
    
    public String getID(){
        return this.id;
    }
    
    public ResourceWeights getResourcePreferenceWeight(){
        return this.prw;
    }
    
    public double getPreferedResourceCount(Resource r){
        return this.prw.getPreferedResourceTable().get(r);
    }
    
    public void logIn(){
        this.login = true;
    }
    
    public boolean isLogIn(){
        return this.login;
    }
    
    /**
     * rptable을 바탕으로 ResourcePreference 생성
     * @param upt 
     */
    private void initializePreferedResourceWeight(Hashtable<Resource, Integer> upt){
        this.prw = new ResourceWeights(upt);
        ResourceWeights temprw = Normalization.normalizePreferedResourceByMinMax(upt);
        this.prw.putAll(temprw);
    }
        
    /**
     * 입력된 Resource set을 바탕으로 rptable 업데이트
     * @param rset 
     */
    public void update(Vector<Resource> rset){
                
    }
        
}
